home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 March / EnigmA AMIGA RUN 05 (1996)(G.R. Edizioni)(IT)[!][issue 1996-03][Skylink CD IV].iso / earcd / program / ixemlsrc.lha / ixemul / library / parse_version.c < prev    next >
C/C++ Source or Header  |  1995-12-23  |  1KB  |  56 lines

  1. #include <stdio.h>
  2.  
  3. int main(int argc, char **argv)
  4. {
  5.   FILE *f;
  6.   int major, minor, day, month, year;
  7.   char pathname[1024];
  8.   
  9.   if (argc != 2)
  10.   {
  11.     fprintf(stderr, "Usage: parse_version <srcdir>\n");
  12.     exit(2);
  13.   }
  14.   strcpy(pathname, argv[1]);
  15.   strcat(pathname, "/../version.in");
  16.   f = fopen(pathname, "r");
  17.   if (f == NULL)
  18.   {
  19.     fprintf(stderr, "Cannot open %s\n", pathname);
  20.     exit(2);
  21.   }
  22.   fscanf(f, "%d.%d,%d.%d.%d", &major, &minor, &day, &month, &year);
  23.   fclose(f);
  24.   strcpy(pathname, argv[1]);
  25.   strcat(pathname, "/version.c");
  26.   f = fopen(pathname, "w");
  27.   fprintf(f, "/*\n * version.c file. Automatically generated by parse_version.\n */\n\n");
  28.   fprintf(f, "static const char version_id[] = \"\\000$VER: ixemul.library %d.%d (%d.%d.%d)\";\n",
  29.              major, minor, day, month, year);
  30.   fclose(f);
  31.   strcpy(pathname, argv[1]);
  32.   strcat(pathname, "/version.h");
  33.   fopen(pathname, "w");
  34.   fprintf(f, "/*
  35.  * version.h file. Automatically generated by parse_version.
  36.  */
  37.  
  38. #ifndef __VERSION_H__
  39. #define __VERSION_H__
  40.  
  41. /* *BLOODY* commodities.h defines IX_VERSION too, so wait for our defines
  42.    to come last, and undef the sucker now!! */
  43. #undef IX_VERSION
  44.  
  45. #define IX_NAME        \"ixemul.library\"
  46. #define IX_IDSTRING    \"ixemul %d.%d (%d.%d.%d)\"
  47. #define IX_VERSION    %d
  48. #define IX_REVISION    %d
  49. #define IX_PRIORITY    0
  50.  
  51. #endif
  52. ", major, minor, day, month, year, major, minor);
  53.   fclose(f);
  54.   return 0;
  55. }
  56.